﻿using Model;
using Newtonsoft.Json;
using PrintLabel.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 纺织贸易管理系统;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;

namespace PrintLabel.Tools
{
    public class FileHelper
    {
        public static void 保存信息(Temp temp)
        {
            File.WriteAllText(Application.StartupPath + "//Temp.json", JsonConvert.SerializeObject(temp));
        }
        public static Temp 读取信息()
        {
            try
            {
                if (File.Exists(Application.StartupPath + "//Temp.json"))
                {
                    return JsonConvert.DeserializeObject<Temp>(File.ReadAllText(Application.StartupPath + "//Temp.json"));
                }
                else
                {
                    return new Temp();
                }
            }
            catch (Exception ex)
            {
                ShowMessage.ShowErrorMessagebox(new Form(), "读取文件失败，错误信息是：" + ex.Message);
                return new Temp();
            }
        }
    }
}
